---
category: Level 1 — Basic
created: '2020-02-18'
keywords:
title: Prepend to an element
---

Add the `ele` element to the beginning of the `target` element:

```js
target.insertBefore(ele, target.firstChild);
```

## See also

-   [Append to an element](https://phuoc.ng/collection/html-dom/append-to-an-element/)
-   [Insert an element after or before other element](https://phuoc.ng/collection/html-dom/insert-an-element-after-or-before-other-element/)
-   [Insert given HTML after or before an element](https://phuoc.ng/collection/html-dom/insert-given-html-after-or-before-an-element/)
